//
//  swift_learningTests.swift
//  swift_learningTests
//
//  Created by arons on 2016/12/6.
//  Copyright © 2016年 arons. All rights reserved.
//

import XCTest
import UIKit
import Foundation
@testable import swift_learning


class swift_learningTests: XCTestCase {
    
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    func testExample() {

        let d = BlockDemo()
        d.test();
        
//        waitForExpectations(timeout: 5, handler: nil)
        
        waitForExpectations(timeout: 5);
    }
    
    func testPerformanceExample() {
        // This is an example of a performance test case.
        self.measure {
            // Put the code you want to measure the time of here.
        }
    }
    
    // 测试自定义的Log
    func testCustomLog() {
        BMLOG("XX");
        BMLOG(90);
        BMLOG(self);
        BMLOG(("zhangsan", "azz", "bbb"));
        BMLOG((name: "zhangsan", age: "azz", height: "bbb"));
        BMLOG(["zhangsan", "azz", "bbb"]);
        BMLOG(["name": "zhangsan", "age": "azz", "height":"bbb"]);
    }
    
    func BMLOG(_ message: Any, file: String = #file, funcName: String = #function, line: Int = #line) {
        let resultFile = (file as NSString).lastPathComponent;
        
        print("\(resultFile) ## \(funcName) # \(line):\(message)")
    }
    
    // 测试正则表达式
    func testRegulation() {
        // 创建规则
        let pattern = "abc"
        let matchStr = "abcabc"
        
        let regex = try? NSRegularExpression(pattern: pattern, options: .allowCommentsAndWhitespace)
        let result = regex?.matches(in:matchStr , options: .reportCompletion, range: NSMakeRange(0, matchStr.characters.count))
        result?.count
    }
    
}
